package org.example.dev.controller;


import org.example.dev.pojo.ImageGeneration;
import org.example.dev.service.IImageService;
import org.example.dev.service.ISDService;
import org.example.dev.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import translate.Translate;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;

@RestController
@RequestMapping("/api/sd")
public class SDController {
    @Autowired
    private ISDService isdService;

    @Autowired
    private IImageService imageService;

    @Autowired
    private IUserService userService;


//    @PostMapping("/textToImage")
//    public ResponseEntity<String> textToImage(@RequestParam String textDescription) {
//        //文本翻译
//        Translate translate = new Translate();
//        try{
//            String textTranslationDescription = translate.translate(textDescription);
//            String imageUrl = isdService.textToImage(textTranslationDescription);
//            imageService.insertImage(imageUrl, textDescription, 1);
//            return ResponseEntity.ok(imageUrl);
//        } catch (IOException e) {
//            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error generating image from text");
//        } catch (NoSuchAlgorithmException e) {
//            throw new RuntimeException(e);
//        }
//    }
//
//    @PostMapping("/imageToImage")
//    public ResponseEntity<String> imageToImage(@RequestParam String imageUrl) {
//        try {
//            String newImageUrl = isdService.imageToImage(imageUrl);
//            imageService.insertImage(newImageUrl, imageUrl, 2);
//            return ResponseEntity.ok(newImageUrl);
//        } catch (IOException e) {
//            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error generating new image from image");
//        }
//    }
}



